

# a = 10

# if a < 5:
#     print("hehe")
# elif a == 5:
#     print("haha")
# else:
#     print("裂开")


# i = 0
# while i < 5:
#     print("haha")
#     i += 1

# ans = 0
# for i in range(1, 101):
#     ans += i

# print(ans)


# str = "my name is chen"

# for i in str:
#     print(i)

# list1 = ["zhangsan", "lisi", "wangwu"]

# for i in list1:
#     print(i, end = " ")


# import random

# while True:
#     print(random.randint(0, 5))



# for i in range(1, 5):
#     print(i)

# else:
#     print("正常结束")


# i = 0
# while i < 5:
#     if(i == 3):
#         break;
    
#     print(i)
#     i += 1

# else:        # else还有一个作用， 判断上面的循环是否是正常退出
#     print("正常终止")


# def Printf():
#     print("hehe")


# Printf()
# Printf()
# Printf()
# Printf()



    

# from matplotlib import pyplot as plt

# plt.plot([1,2,3,4])
# plt.show()


# def fun1():
#     print("hello chen")


# fun1()


# def fun2(info1):
#     print(f"info1 = {info1}")


# fun2(123)
# fun2("hello wordl")


# def fun4(*args):  # args的类型是元组  （不可修改的）
#     print(type(args))
#     for i in args:
#         print(i)


# fun4(1, 2, 3, 4, 5, "15")

# 函数的参数可以从右向左缺省
# def fun5(**kargs):  # kargs默认是字典
#     print(type (kargs))
#     print(kargs.keys())


# fun5(name = "zhangsan", age = "李四")

# def fun6(a:int, b:int):
#     print(a + b)


# fun6(1, 2)
# fun6("hehe", "haha")


# class Person:

#     #这个类似于默认构造函数
#     def __init__(self, name, sex = "男", hobby = "听歌") -> None:
#         self.name = name
#         self.sex = sex
#         self.hobby = hobby
    
#     def eat(self):
#         print("吃饭了")


# p = Person("张三", "女", "洗头")
# print(p.name)
# p.eat()


# import module   # 引入一个模块的所有内容

# module.fun1(100, 200)


# from module import fun1  # 引入一个模块中的具体功能
# fun1(1000, 2000)



# import os

# print(os.getcwd()) # 获取当前的工作目录  C:\Users\2426\pycode_vs
# print(os.path.abspath('test2.py')) # 获取当前文件的绝对路径

# #获取上层文件夹的绝对路径
# print(os.path.dirname(r'C:\Users\2426\pycode_vs\test2.py'))

# print(os.path.exists("test2.py"))  # 判断存在文件
# print(os.path.exists("test3.py"))

# #分割文件名和前一部分 xxxx   test2.py
# print(os.path.split(r'C:\Users\2426\pycode_vs\test2.py'))

# #分割文件的后缀     xxxx   .py
# print(os.path.splitext(r'C:\Users\2426\pycode_vs\test2.py'))

# print(os.path.isfile('test2.py'))  # 判断是不是文件
# print(os.path.isdir('test2.py'))  # 判断是不是路径



import os

# 创建和删除文件夹
# os.makedirs('tmp')
# os.rmdir('tmp')


# f = open('aaa.py', 'w')
# f.write('hello python\n')
# f.write('hello python\n')
# f.write('hello python\n')
# f.write('hello python\n')

# f.close()

# with可以自动关闭文件夹
# with open('aaa.py', 'a') as f: 
#      f.write("hehe\n")
#      f.write("haha\n")                    # 追加的方式


with open('aaa.py', 'r') as f:
    print(f.read(5))      #默认是全部读完
    print(f.read(5))
